﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace NumberOfOccurrences
{
    
    public class SubstringOccurrencesService : ISubStringOccurrences
    {

        public int GetData(string container, string toLook)
        {
            int occurrences = 0;
            int index = 0;
            index = container.IndexOf(toLook,index);
            while(index>=0)
            {
                occurrences++;
                index = container.IndexOf(toLook, index+1);
            }
            return occurrences;
        }
    }
}
